#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

vector<string> getFolderNames(vector<string>& names) {
    vector<string> ans;
    unordered_map<string, int> hash;
    for (auto str : names) {
        if (hash[str] == 0) {
            hash[str]++;
            ans.push_back(str);
        }
        else {
            string tmp = str;
            tmp += "(1)";
            int i = 2;
            int size = tmp.size();
            while (hash[tmp] != 0) {
                tmp[size - 1 - 1] = '0' + i;
                i++;
            }
            hash[tmp]++;
            ans.push_back(tmp);
        }
    }

    for (auto e : ans)
        cout << e << endl;
    return ans;
}

int main()
{
    vector<string> names = { "onepiece", "onepiece(1)", "onepiece(2)", "onepiece(3)", "onepiece" };
    getFolderNames(names);
}

